package xj.graph2d;

public class ArrowAttr implements Cloneable, java.io.Serializable {

  /**
   * 
   */
  private static final long serialVersionUID = -8287069926050262613L;

  public enum ArrowType {
      NoArrow, 
      LineArrow, 
      HollowTriangle, 
      FilledTriangle, 
      HollowDiamond, 
      FilledDiamond, 
      HollowDot, 
      FilledDot, 
      HalfCircle, 
      FilledHalfMoon, 
      HollowHalfMoon, 
      FilledHalfMoon2, 
      HollowHalfMoon2, 
      CrossDot, 
      XArrow, 
      HollowDiamondArrow, 
      FilledDiamondArrow, 
      HollowDiamondX, 
      FilledDiamondX;

    public static ArrowType getArrowType(int k) {
      for (ArrowType t : ArrowType.values()) {
	if (t.ordinal() == k) {
	  return t;
	}
      }
      return ArrowType.NoArrow;
    }
  }

  public static final int DEFAULT_ARROW_SIZE = 8;

  @Override
  public Object clone() {
    ArrowAttr attr = new ArrowAttr();
    attr.type = type;
    attr.width = width;
    attr.height = height;
    return attr;
  }

  public void copyArrowAttr(ArrowAttr attr) {
    if (attr != null) {
      attr.type = type;
      attr.width = width;
      attr.height = height;
    }
  }

  public ArrowType getType() {
    return type;
  }

  public void setType(ArrowType type) {
    this.type = type;
  }

  public float getWidth() {
    return width;
  }

  public float getHeight() {
    return height;
  }

  public void setWidth(float width) {
    this.width = width;
  }

  public void setHeight(float height) {
    this.height = height;
  }

  public void setSize(float size) {
    width = height = size;
  }

  public float getSize() {
    return height;
  }

  protected ArrowType type = ArrowType.NoArrow;

  protected float width = DEFAULT_ARROW_SIZE;

  protected float height = DEFAULT_ARROW_SIZE;

}
